<%@page pageEncoding="UTF-8" contentType="text/html; charset=UTF-8"
	language="java" import="java.util.*"%>
<%@page import="com.pub.database.*"%>
<%@page import="com.pub.tools.*"%>
<jsp:useBean id="WebFunction" scope="request"
	class="com.pub.web.WebFunction" />
<%
  String prg_status=request.getParameter("prg_status");
  String flow_num=request.getParameter("flow_num");
  String flow_code=flow_num.substring(0,3);
  String flow_no=request.getParameter("flow_no");
  String rout_no="0";//request.getParameter("rout_no");
  String sign_date=com.pub.tools.PublicFunction.getSYSDATE("yyyy/MM/dd HH:mm:ss");
  String r_empno=request.getParameter("r_empno");//簽核者
  String rights=request.getParameter("rights");//是否有權限寫審核意見1:有0:無
  String sign_note=request.getParameter("sign_note");
  Vector<Object> lvtrParam = new Vector<Object>();

  java.util.Hashtable<String,Hashtable<String,Object>> htDetailData=null;
   String strDBAlias=request.getParameter("db_alias");
   String strSrcCharSet=request.getParameter("source_charset");
   String strTarCharSet=request.getParameter("target_charset");
   QueryBean obj=new QueryBean(strDBAlias,false,strSrcCharSet,strTarCharSet);
   String lstrOnloadScript="init();";

try{
  if(rights.equals("0")){
    lstrOnloadScript="alert('無審核意見');window.close();";//無權寫審核意見
  }


  if (prg_status!=null && prg_status.equals("appnote")){
    lvtrParam.add(flow_code);
    lvtrParam.add(flow_num);
    lvtrParam.add(flow_no);
    lvtrParam.add(rout_no);
    lvtrParam.add(PublicFunction.getTimestempDate(sign_date));
    lvtrParam.add(r_empno);
    lvtrParam.add(sign_note);

    String strSql = "insert into wkf_log (flow_code,flow_num,flow_no,rout_no,sign_date,employee_no,sign_note,r_flow_no,r_employee_no,log_st,reject_no)";
    strSql+="values(?,?,?,?,?,?,?,'00','ALL','L','00')";

    boolean blnReturn=obj.executeSQL(strSql,lvtrParam); //執行SQL ,成功傳回true,失敗傳回false
    if (blnReturn){
      lstrOnloadScript="alert('審核意見記錄完成,並立即關閉此頁');window.close();";
    }
  }
}
 catch(Exception e){
   e.printStackTrace();
 }
 finally{

   lvtrParam = null;
   try{obj.close();}catch(Exception e){System.out.println("can not close querybean in action.java");}
   obj=null;
 }
%>
<HTML>
<HEAD>
<LINK HREF="/PUBPAGE/general/workflow.css" REL="STYLESHEET"
	TYPE="TEXT/CSS">
<title>審核意見</title>
<base target='_self' />
<SCRIPT type="text/javascript" language="javascript1.2">

function appCheck(){
   return !(document.form.sign_note.value==null || document.form.sign_note.value=="")
}

function evt_btn_confirm_onclick(){
  if(appCheck()){
    document.all.item("prg_status").value= "appnote";
    document.form.submit();
  }
  else{
    alert("請填寫審核意見");
    return false;
  }
}

//開窗置中
 function init()
 {
  window.moveTo((screen.width-document.body.clientWidth)/2-5,(screen.height-document.body.clientHeight)/2-60);

}
</SCRIPT>
</HEAD>
<BODY
	onLoad="javascript:<%=lstrOnloadScript==null ? "" : lstrOnloadScript%>">

<CENTER>

<FORM NAME="form" METHOD=POST action="app_note.jsp"><BR>
<div id="app_note" style="DISPLAY=<%=rights.equals("1") ? "" : "none"%>">
<TABLE BORDER="0" WIDTH="540" CELLSPACING="1" CELLPADDING="0">
	<TR>
		<TD ID="td_sign_note" CLASS="td_head_1" WIDTH="18%">填寫審核意見：</TD>
		<TD CLASS="td_content_1" WIDTH="82%"><TEXTAREA rows="5"
			cols="75" NAME="sign_note" CLASS="textarea"></TEXTAREA></TD>
	</TR>
</TABLE>
<TABLE BORDER="0" WIDTH="540" CELLSPACING="0" CELLPADDING="0">
	<TR>
		<TD CLASS="td_head_1" WIDTH="100%" ALIGN="CENTER"><INPUT
			type="button" name='confirm' value='確定' CLASS="button b_normal"
			onClick="javascript:evt_btn_confirm_onclick();" /> <INPUT
			type="reset" name='cancel' value='清除' CLASS="button b_normal" /> <INPUT
			type="button" name='exit' value='離開' CLASS="button b_normal"
			onClick="window.close();" /> <INPUT TYPE="hidden" NAME="prg_status"
			value="<%=prg_status%>" /> <input type="hidden" name="flow_num"
			value="<%=flow_num%>" /> <input type="hidden" name="flow_no"
			value="<%=flow_no%>" /> <input type="hidden" name="rout_no"
			value="<%=rout_no%>" /> <input type="hidden" name="r_empno"
			value="<%=r_empno%>" /> <input type="hidden" name="db_alias"
			value="<%=strDBAlias%>" /> <input type="hidden" name="target_charset"
			value="<%=strTarCharSet%>" /> <input type="hidden"
			name="source_charset" value="<%=strSrcCharSet%>" /> <input
			type="hidden" name="rights" value="<%=rights%>" /></td>
	</TR>
</TABLE>
</div>
</FORM>
</center>
</BODY>
</HTML>
